<?php (!defined('IN_SYSTEM') || !defined('ADMIN_PRE')) && exit('Access Denied!');?>
{admintemplate header}
<div class="box">
	<div class="heading">
	<h1>列表</h1>
	<div class="buttons">
	<a href="{url admin.php?m=opelog}" class="fr">列表</a>
	<a href="{url admin.php?m=opelog&f=stat}" class="fr">报表</a>
	<a href="{url admin.php?m=opelog&f=add}" class="fr">添加</a>
	</div>
	</div>
	<div class="main">
		{if !$_GET['f'] || $_GET['f'] == 'index'}
		<div class="search">
			<form name="search" method="get" action="{url admin.php}" autocomplete="off">
			<input type="hidden" name="m" value="opelog" />
				<fieldset>
					<legend>条件搜索</legend>
					月份：
						<select name="opdate">
							<option value="1970-01">全部</option>
							{loop $searchs $k $v}
							<option value="{$k}" {if $opdate==$k}selected{/if}>{$v}</option>
							{/loop}
						</select>
						<input type="submit" name="s" class="button" value="搜索" />
						{gdate('Y年m月',$start['bdate'])}:月初账户总值:{$start['btotal']}，当前账户总值{$stotal}，收益率:{echo round(($p+$loss)*100/$start['btotal'],2)}%，相对收益率:{echo round(($p+$loss)*100/($start['btotal']*$rate/$allrate),2)}%，大盘涨跌:{round(($sdapan-$start['bdapan'])*100/$start['bdapan'],2)}%，暂停操作额度:{echo round($maxtotal*0.94,2)} {if $stotal<$maxtotal*0.94}， <b>暂停操作</b>{/if}
				</fieldset>
			</form>
		</div>	
		<div style="line-height:21px;">
		交易次数:{$cnum}，盈利次数:{$pnum}，亏损次数:{$lossnum}，<b><span title="盈利的次数(卖出后账户资金大于买入前账户资金)占比">赢率</span>:{echo round($pnum*100/$cnum,2)}%</b>，1R:{echo round($_1R*100/$cnum,2)}%，2R:{echo round($_2R*100/$cnum,2)}%，<b title="盈利大于预计亏损4倍的交易数占总交易笔数的比率">4R:{echo round($_4R*100/$cnum,2)}%</b>，10R:{echo round($_10R*100/$cnum,2)}%，大盘涨率:{echo round($dapannum*100/$cnum,2)}%，<span title="手续费+印花税+过户费+其它费用">总费用</span>:-{round($fee,2)}，总亏损:{round($loss,2)}，<b>费用/盈利:{echo round($fee*100/($p+$loss+$fee),2)}%</b>，总盈利:{round($p+$loss,2)}，<span title="平均每次交易费用">平均费用</span>:{echo round($fee/$cnum,2)}，<span title="亏损的交易中，平均每笔亏损">平均亏损</span>:{echo round($loss/$lossnum,2)}，<span title="盈利的交易中，平均每笔盈利">平均盈利</span>:{echo round($p/$pnum,2)}，<b><span title="利润与成本(费用+亏损)比">动态回报率</span>:{echo round($p/($fee+$lossp),1)}</b>，<span title="动用总资金/月初资金">资金周转率</span>:{echo round($rate/$start['btotal'],2)}，平均仓位:{echo round($rate*100/$allrate,2)}%，
		单笔最大亏损:-{round($lossmax,2)}，单笔最大盈利:{round($pmax,2)}，最大连续盈利次数:{round($pmaxnum,2)}，最大连续亏损次数:{round($lossmaxnum,2)}，亏损达到2%次数:{$stopnum}，</div>
		<table cellspacing="0" class="list" id="list">
			<thead>
				<tr>
					<td>买进 / 卖出时间</td>
					<td>代码</td>
					<td>买前/卖后账户总额</td>
					<td>买/卖指数(涨跌)</td>
					<td>买入</td>
					<td>占总资金</td>
					<td>卖出</td>
					<td>涨跌</td>
					<td>费用</td>
					<td>盈亏</td>
					<td>风险/R乘数</td>
					<td>操作</td>
				</tr>
				</thead>
			{loop $results $result}	
				<tr>{php $fees=$profile=0;}
					<td class="center">{gdate('Y m.d',$result['bdate'])}/{if $result['sdate']>0}{gdate('m.d',$result['sdate'])}{/if}</td>
					<td class="center"><span title="{$result['body']}" style="cursor:pointer;">{$result['code']}</span></td>
					{if $result['btotal']<1}
					<td colspan="10">{$result['body']}</td>
					{else}
					<td class="center">{$result['btotal']}/{$result['stotal']}</td>
					<td class="center">{$result['bdapan']}/{$result['sdapan']} {if $result['sdapan']>0}({echo round(($result['sdapan']-$result['bdapan'])*100/$result['bdapan'],2)}%){/if}</td>
					<td class="center">{$result['bprice']}/{$result['bamount']}</td>
					<td class="center">{echo round($result['bamount']*$result['bprice']*100/$result['btotal'],2)}%</td>
					<td class="center">{$result['sprice']}/{$result['samount']}</td>
					<td class="center">{if $result['sprice']>0}{echo round(($result['sprice']-$result['bprice'])*100/$result['bprice'],2)}%{/if}</td>
					<td class="center">{if $result['stotal']>0}{php $fees=round($result['sprice']*$result['samount']-$result['bprice']*$result['bamount']-$result['stotal']+$result['btotal'],2);echo $fees;}
					 {/if}</td>
					<td class="center">{if $result['stotal']>0}{php $profile=round($result['stotal']-$result['btotal'],2);echo $profile;}
					{/if}</td>
					<td class="center">{if $result['lprice']>0}{echo round(($result['bprice']-$result['lprice'])*$result['bamount']+$fees)}/{echo round($profile/(($result['bprice']-$result['lprice'])*$result['bamount']+$fees),1)}{/if}</td>
					{/if}
					<td align="center"><a href="{url admin.php?m=opelog&f=edit&id=$result[id]}">编辑</a></td>
				</tr>
		{/loop}
			</table>
			{pager($totalnum,$pagesize)}
		{/if}
		{if $_GET['f'] == 'add' || $_GET['f'] == 'edit'}
		{script('calendar.js')}
			<form action="{url admin.php?m=opelog}" method="POST" class="uc_search" autocomplete="off">
			<input type="hidden" value="{$id}" name="id"/>
			<input type="hidden" value="save" name="f"/>
			<input type="hidden" value="true" name="opelogsubmit"/>
			<table cellspacing="0" class="uc_fa_table">
			<tr><td><table>
			<tr><td class="td1">代码：</td><td colspan="3"><input type="text" name="code" class="input" size="32" value="{$result['code']}" /></td></tr>
			<tr><td class="td1">买入时间：</td><td colspan="3"><input type="text" name="bdate" class="input" size="32" value="{if $result['bdate']}{gdate('Y-m-d',$result['bdate'])}{else}{gdate('Y-m-d',TIMESTAMP)}{/if}" onclick="showcalendar(event);" /></td></tr>
			<tr><td class="td1">买前账户总额：</td><td colspan="3"><input type="text" name="btotal" class="input" size="32" value="{if $result['btotal']}{$result['btotal']}{else}{$stat['stotal']}{/if}" /></td></tr>
			<tr><td class="td1">买时指数：</td><td colspan="3"><input type="text" name="bdapan" class="input" size="32" value="{if $result['bdapan']}{$result['bdapan']}{else}{$stat['sdapan']}{/if}" /></td></tr>
			<tr><td class="td1">买入价格：</td><td colspan="3"><input type="text" name="bprice" class="input" size="32" value="{$result['bprice']}" /></td></tr>
			<tr><td class="td1">买入数量：</td><td colspan="3"><input type="text" name="bamount" id="bamount" class="input" size="32" value="{$result['bamount']}" /></td></tr>
			<tr><td class="td1">买入手续费：</td><td colspan="3"><input type="text" name="bshouxu" id="bshouxu" class="input" size="32" value="{$result['bshouxu']}" /></td></tr>
			<tr><td class="td1">买入印花税：</td><td colspan="3"><input type="text" name="bshui" id="bshui" class="input" size="32" value="{$result['bshui']}" /></td></tr>
			<tr><td class="td1">买入过户费：</td><td colspan="3"><input type="text" name="bguohu" id="bguohu" class="input" size="32" value="{$result['bguohu']}" /></td></tr>
			
			</table>
			</td><td><table>
			<tr class="bg2"><td class="td1">止损价格：</td><td colspan="3"><input type="text" name="lprice" class="input" size="32" value="{$result['lprice']}" /></td></tr>
			<tr><td class="td1">卖出时间：</td><td colspan="3"><input type="text" name="sdate" class="input" size="32" value="{if $result['bdate']}{gdate('Y-m-d',$result['sdate'])}{else}{gdate('Y-m-d',TIMESTAMP)}{/if}"    onclick="showcalendar(event);" /></td></tr>
			<tr><td class="td1">卖后账户总额：</td><td colspan="3"><input type="text" name="stotal" class="input" size="32" value="{$result['stotal']}" /></td></tr>
			<tr><td class="td1">卖时指数：</td><td colspan="3"><input type="text" name="sdapan" class="input" size="32" value="{$result['sdapan']}" /></td></tr>
			<tr><td class="td1">卖出价格：</td><td colspan="3"><input type="text" name="sprice" class="input" size="32" value="{$result['sprice']}" /></td></tr>
			<tr><td class="td1">卖出数量：</td><td colspan="3"><input type="text" name="samount" id="samount" class="input" size="32" value="{$result['samount']}" /><span onclick="$('#samount').val($('#bamount').val());" style="cursor:pointer;">和买入数量相同</span></td></tr>
			<tr><td class="td1">卖出手续费：</td><td colspan="3"><input type="text" name="sshouxu" id="sshouxu" class="input" size="32" value="{$result['sshouxu']}" /></td></tr>
			<tr><td class="td1">卖出印花税：</td><td colspan="3"><input type="text" name="sshui" id="sshui" class="input" size="32" value="{$result['sshui']}" /></td></tr>
			<tr><td class="td1">卖出过户费：</td><td colspan="3"><input type="text" name="sguohu" id="sguohu" class="input" size="32" value="{$result['sguohu']}" /></td></tr>
			
			</table>
			</td></tr>
			<tr><td class="td1" colspan="2" style="vertical-align:top;"><font style="margin-right:31px;">交易总结：</font><textarea cols="79" rows="7" name="body">{$result['body']}</textarea></td></tr>
			
			<tr class="bg2"><td class="td1"></td><td colspan="1"><input type="submit" class="button" value="保存" /> </td></tr>
			</table>
			</form>
			
		{/if}	

		
	</div>
</div>
{admintemplate footer}